<?php
$pid = $_REQUEST['pid']; //'116519985036757';//$option['toolFBPageID'];
//echo $pid;
$home_url = $_REQUEST['url'];
$path = $_REQUEST['path'];
$config ['facebook_api_key'] = $_REQUEST['api_key'];
$config ['frontendCss'] = "{$path}css/frontend/";
$config ['frontendScript'] = "{$path}scripts/frontend/";
$config['pluginPath'] = "{$path}";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="<?php echo $config ['frontendCss'] ?>facebook/my.css" type="text/css" rel="stylesheet">
        <link href="<?php echo $config ['frontendCss'] ?>facebook/fb.css" type="text/css" rel="stylesheet">

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
        <script type="text/javascript" src="<?php echo $config ['frontendScript'] ?>toolbar/actions.js"></script>
        <script type="text/javascript" src="<?php echo $config ['frontendScript'] ?>toolbar/fbpage.js"></script>
        <script type="text/javascript">
            var pid=<?php echo $pid; ?>;
            var selectedFilter = 0;
            function _fun_registeraction(_ActionId,_MetaData,_MetaType)
            {
                //flik_reg(27,'339196','767632',_ActionId,_MetaData,_MetaType);
            }

            jQuery(document).ready(function(){
                var post_data = "page=stToolBar&type=getPageName&action=getFbFeed&pid="+pid+"&ajax=1&url=<?php echo $home_url ?>";
                var ajax_url = '<?php echo $home_url ?>?'+post_data;
                //	jQuery(".socialmediatoolboxes_tw_loader").hide();
                setMenuBehavior('<?php echo $home_url ?>', '<?php echo $path ?>');
                // Obtain Page Name
                jQuery.ajax({
                    type: "POST",
                    url: ajax_url,
                    success: function(msg){
                        if (msg == '') {
                            msg = 'Fan Page';
                        }
                        jQuery("#filter1 span").html('Just '+msg);
                    }
                });

                post_data = "page=stToolBar&type=getAll&action=getFbFeed&pid="+pid+"&ajax=1&url=<?php echo $home_url ?>";
                ajax_url = '<?php echo $home_url ?>?'+post_data;
                // Get Stream for all
                jQuery.ajax({
                    type: "POST",
                    url: ajax_url,
                    beforeSend: function(){
                        jQuery('.loader_div').show();
                    }, //show loading just when link is clicked
                    complete: function(){
                        jQuery('.loader_div').hide();
                    },
                    success: function(msg){
                        jQuery(".socialmediatoolboxes_tw_stream_body").html(msg);
                        jQuery(".loader_div").hide();
                    }
                });
            });
            var stToolbar = {
                closeWindow: function(){
                    parent.top.jQuery("#draggable").fadeOut();
//                    jQuery("#fbFanPageIframe").css('display', 'none');
                }
            }
        </script>

        <title></title>
    </head>
    <body style="background: transparent">
        <div id="fbFanPageIframe">            
            <div class="socialmediatoolboxes_wiwi_body_main" style="height: 430px; ">
                <div id="socialmediatoolboxes_wiwi_bl">
                </div>
                <div  class="socialmediatoolboxes_wiwi_body" style="height: 430px; width: 790px; padding-top:5px;">
                    <div class="socialmediatoolboxes_tw_left_panel">
                        <div id="socialmediatoolboxes_tw_loader_left" class="socialmediatoolboxes_tw_loader" style="display: none;">
                            <div class="socialmediatoolboxes_tw_loader_img"><img src="<?php echo $config ['frontendCss'] ?>facebook/images/6nr0un50.gif"/></div>
                        </div>

                        <div id="socialmediatoolboxes_tw_body_left">
                            <iframe style="overflow: hidden;" height="316" frameborder="0" width="370" scrolling="no"  src="http://www.facebook.com/connect/connect.php?id=<?php echo $pid; ?>&connections=18&stream=0">Facebook</iframe>
                            <br clear="both" />
                            <div
                                style="background-color: white; border: 1px solid rgb(148, 163, 196); margin-top: 9px;"
                                id="user_panel">
                                <table width="100%">
                                    <tbody>
                                        <tr height="77">
                                            <td align="center">
                                                <table height="75" width="100%">
                                                    <tbody>
                                                        <tr>
                                                            <td align="center" width="60" valign="top"><img
                                                                    src="<?php echo $config ['frontendCss'] ?>facebook/images/fbpic.png" alt="Not Connected" title="Not Connected"
                                                                    class="FB_profile_pic fb_profile_pic_rendered"></td>
                                                            <td align="left" valign="top">
                                                                <div class="status_textbox">

                                                                    <textarea disabled="disabled"
                                                                              name="shoutbox_textarea" id="shoutbox_input"
                                                                              class="shoutbox_textarea"
                                                                              title="In order to post a message on the fan page you need to connect first"
                                                                              rows="2" cols="20">In order to post a message on the fan page you need to connect first
                                                                    </textarea>

                                                                    <fb:login-button background="white" size="fb:login-button"
                                                                                     class=" fb_login_not_authorized FB_login_button FB_ElementReady">
                                                                    </fb:login-button></div>
                                                            </td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>

                            <br clear="both" />

                        </div>
                    </div>
                    <div class="socialmediatoolboxes_tw_right_panel">
                        <div id="socialmediatoolboxes_tw_loader_right" class="socialmediatoolboxes_tw_loader" style="display: none;">
                            <div class="socialmediatoolboxes_tw_loader_img"><img src="<?php echo $config ['frontendCss'] ?>facebook/images/loading.gif"/></div>

                        </div>
                        <div id="socialmediatoolboxes_tw_body_right" class="socialmediatoolboxes_tw_body">
                            <div class="socialmediatoolboxes_tw_stream_header">
                                <div class="socialmediatoolboxes_tw_stream_header_text">
                                    Page Latest Activity
                                </div>
                                <div class="stream_header_menu">
                                    <div id="filter0" class="stream_header_menu_item_on">
                                        <span>Show All</span>

                                    </div>
                                    <div id="filter1" class="stream_header_menu_item_off">
                                        <span>Just</span>
                                    </div>
                                    <div id="filter2" class="stream_header_menu_item_off">
                                        <span>Just Fans</span>
                                    </div>
                                    <div class="loader_div">

                                        <img src="<?php echo $config ['frontendCss'] ?>facebook/images/6nr0un50.gif" />
                                    </div>
                                </div>
                            </div>
                            <div class="socialmediatoolboxes_tw_stream_body">
                            </div>
                        </div>
                        <br clear="both" />
                    </div>
                </div>
                <div id="socialmediatoolboxes_wiwi_br">
                </div>
            </div>
            
            <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>

            <script type="text/javascript">
    
                FB_RequireFeatures(["XFBML","Api"], function() {//5fdaecdd9f7d77dc345ac9179a99a0c9
                    FB.Facebook.init("<?php echo $config['facebook_api_key']; ?>", "<?php echo $config['pluginPath'] . 'xd_receiver.htm'; ?>",{"ifUserConnected":onConnected,"ifUserNotConnected":onNotConnected});
                });
            </script>
        </div>
    </body>
</html>